<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html >
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>我的商品分类</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="res/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="res/css/bootstrap-responsive.min.css">
    <link rel="stylesheet" type="text/css" href="res/css/style.css">
    
    <script type="text/javascript" src="res/js/jquery-1.9.1.min.js"></script>
  </head>
  
  
  
  <body>
    <%@include file="../template/header.jsp" %>
    
    <div class="subHead">
        <div class="container">
            <h1>商家管理后台</h1>
            <p class="lead">商家可以在此修改商品，修改商品类别，添加子店铺账户（总店管理员）等。</p>
        </div>
    </div>
    
    <div class="row mainContent">
        
        <%@include file="../template/shopNav.jsp" %>
        
        <div class="span9">
        	<legend class="text-warning">商品类别</legend>
        	<table class="table table-striped table-hover">
                <thead>
	                <tr>
	                    <th>#</th>
	                    <th>类型名称</th>
	                    <th>父类型</th>
	                    <th>修改\删除</th>
	                </tr>
                </thead>
                <tbody>
               		<s:iterator value="#request.categories" id="categories" status="statu">
               			<s:iterator value="#categories" id="category" status="subStatu">
               				<tr>
               					<td>
               						<s:if test="#subStatu.index == 0">
               							<s:property value="#statu.index + 1" />
               						</s:if>
               						<s:else>
               							<s:iterator begin="0" end="(#category.deep-1) * 3">-</s:iterator>
               							<s:property value="#statu.index + 1" />.<s:property value="#subStatu.index" />
               						</s:else>
               					</td>
               					<td><s:property value="#category.name" /></td>
               					<td><s:property value="#category.parent.name" /></td>
               					<td>
               						<a href="#" class="btn btn-mini" data-toggle="modal" data-target="#myModal">修改</a>
               						&nbsp;&nbsp;
               						<a name="delete" href="shop/deleteMyCategory.htm?categoryId=<s:property value="#category.id"/>">删除</a>
               					</td>
               				</tr>
               			</s:iterator>
               		</s:iterator>
                </tbody>
             </table>
        </div>
        <div id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" class="modal hide fade">
	    	<div class="modal-header">
			    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			   	<h3>修改类别信息</h3>
			</div>
			    
			<div class="modal-body">
			   	<div class="span5">
            		<form class="form-horizontal">
	                	<legend class="text-warning">修改类别信息</legend>
	                
	               		<div class="control-group">
	                    	<label class="control-label" for="cateGoryName">类别名称</label>
		                	<div class="controls">
		                        <input type="text" id="name" name="name" placeholder="请输入类别名称" 
		                        	value='<s:property value="#request.target.name"/>'>
		                	</div>
		             	</div>
	                
	                 	<div class="control-group">
	                    	<label class="control-label" for="categoryParentId">父类型</label>
	                    	<div class="controls">
	                       		<select id="categoryParentId" name="categoryParentId">
	                       			<option value="-1" selected="selected">没有父类型</option>
	                       			<s:iterator value="#request.categories" id="parent">
		                       			<option value='<s:property value="#parent.id"/>'>
		                       				<s:property value="#parent.name" />
		                       			</option>
	                       			</s:iterator>
	                       		</select>
	                    	</div>
	                	</div>
	            	</form>
        		</div>
			</div>
			    
			<div class="modal-footer">
			    <button id="closeBtn" type="button" class="btn" onclick="close()">Close</button>
			    <a href="#" class="btn btn-primary" onclick="saveChanges()">Save changes</a>
		    </div>
	   	 </div>
    </div>
    
    <div class="footer">
        <p>版权所有： 银盒子计划团队</p>
    </div>

    <script type="text/javascript" src="res/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        $('a[name=delete]').each(function(){
            var that = $(this);
            that.on('click', function(){
                if(confirm('确定删除此商品？')){
                    return;
                }
                else {
                    return false;
                }
            });
        });
        
        $('li[name=templateHeader]').each(function(){
    	var that = $(this);
    	that.removeClass("active");
    
	    });
		$("#templateHeader2").addClass("active"); 
		
		$('li[name=shopNav]').each(function(){
	        	var that = $(this);
	        	that.removeClass("active");
	    });
	    $("#shopNav3").addClass("active");  
        
        function close(){
        	alert(0);
        	$("#myModal").modal("hide");
        	alert(0);
        	return false;
        }
        
        function saveChanges(){
        
        	
        }
    </script>
  </body>
</html>
